#!/bin/bash

# 本脚本将会自动安装
# 0. git
# 1. tmux
# 2. .tmux
# 3. zsh
# 4. oh-my-zsh

# 判断系统版本

cent_os_path="/etc/redhat-release"
issue_file_path="/etc/issue"

shell_dirname=$(dirname $0)
ubuntu_script="scripts/ubuntu.sh"

# 设置权限
$(chmod 755 "${shell_dirname}/${ubuntu_script}")

echo '=== Welcome to use terminal auto-config script! ==='
if [[ `uname` == 'Darwin' ]]; then 
    # 如果是macOS系统
    echo "Sorry, but we don't have time to make a macOS version script."
elif [[ `uname` == 'Linux' ]]; then
    if test -e "$cent_os_path"; then
        echo " * Your OS is CentOS"
    elif test -e "$issue_file_path"; then
        issue_info=$(cat $issue_file_path)
        if [[ $issue_info =~ 'Ubuntu' ]]; then
            echo " * Your OS is Ubuntu"
            exec "${shell_dirname}/${ubuntu_script}"
            # $($ubuntu_script)
        elif [[ $issue_info =~ 'CentOS' ]]; then
            echo " * Your OS is CentOS"
        fi
    fi
fi
